package o;

import android.content.Context;
import android.graphics.Rect;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import android.widget.PopupWindow.OnDismissListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.menu.MenuAdapter;

public abstract class bm implements bt, bn, OnItemClickListener {
    private Rect ˋ;

    public abstract void ˊ(bd bdVar);

    public abstract void ˎ(int i);

    public abstract void ˎ(View view);

    public abstract void ˎ(boolean z);

    public abstract void ˏ(int i);

    public abstract void ॱ(int i);

    public abstract void ॱ(OnDismissListener onDismissListener);

    public abstract void ॱ(boolean z);

    protected bm() {
    }

    public void ˋ(Rect rect) {
        this.ˋ = rect;
    }

    public Rect ॱॱ() {
        return this.ˋ;
    }

    public void ˏ(@NonNull Context context, @Nullable bd bdVar) {
    }

    public boolean ˏ(bd bdVar, bj bjVar) {
        return false;
    }

    public boolean ˎ(bd bdVar, bj bjVar) {
        return false;
    }

    public int ॱ() {
        return 0;
    }

    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        ListAdapter listAdapter = (ListAdapter) adapterView.getAdapter();
        ॱ(listAdapter).mAdapterMenu.ˊ((MenuItem) listAdapter.getItem(i), this, ʻ() ? 0 : 4);
    }

    protected static int ˏ(ListAdapter listAdapter, ViewGroup viewGroup, Context context, int i) {
        int makeMeasureSpec = MeasureSpec.makeMeasureSpec(0, 0);
        int makeMeasureSpec2 = MeasureSpec.makeMeasureSpec(0, 0);
        int count = listAdapter.getCount();
        int i2 = 0;
        int i3 = 0;
        View view = null;
        int i4 = 0;
        ViewGroup viewGroup2 = viewGroup;
        while (i2 < count) {
            ViewGroup frameLayout;
            int itemViewType = listAdapter.getItemViewType(i2);
            if (itemViewType != i3) {
                i3 = itemViewType;
                view = null;
            }
            if (viewGroup2 == null) {
                frameLayout = new FrameLayout(context);
            } else {
                frameLayout = viewGroup2;
            }
            view = listAdapter.getView(i2, view, frameLayout);
            view.measure(makeMeasureSpec, makeMeasureSpec2);
            int measuredWidth = view.getMeasuredWidth();
            if (measuredWidth >= i) {
                return i;
            }
            if (measuredWidth <= i4) {
                measuredWidth = i4;
            }
            i2++;
            i4 = measuredWidth;
            viewGroup2 = frameLayout;
        }
        return i4;
    }

    protected static MenuAdapter ॱ(ListAdapter listAdapter) {
        if (listAdapter instanceof HeaderViewListAdapter) {
            return (MenuAdapter) ((HeaderViewListAdapter) listAdapter).getWrappedAdapter();
        }
        return (MenuAdapter) listAdapter;
    }

    protected static boolean ˏ(bd bdVar) {
        int size = bdVar.size();
        for (int i = 0; i < size; i++) {
            MenuItem item = bdVar.getItem(i);
            if (item.isVisible() && item.getIcon() != null) {
                return true;
            }
        }
        return false;
    }

    protected boolean ʻ() {
        return true;
    }
}
